package toubiao.domain.po.business;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "contract")
public class PoContract {
	
	
	private Long id;
	
	private String sn;
	
	private Integer seq;
	
	private String name;
	
	private Double amount;
	
	private Date date;
	
	private PoPartA entrustPartA;
	
	private PoPartA constructionPartA;
	
	private Set<PoProject>  projectSet=new HashSet<>();
	
	private Set<PoContact> contactSet=new HashSet<>();
	
	private Set<PoContractPhoto> contractPhotoSet=new HashSet<>();

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}
	
	@Temporal(TemporalType.DATE)  
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "entrustPartA_id")
	public PoPartA getEntrustPartA() {
		return entrustPartA;
	}

	public void setEntrustPartA(PoPartA entrustPartA) {
		this.entrustPartA = entrustPartA;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "constructionPartA_id")
	public PoPartA getConstructionPartA() {
		return constructionPartA;
	}

	public void setConstructionPartA(PoPartA constructionPartA) {
		this.constructionPartA = constructionPartA;
	}

	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "`project-contract`", joinColumns = { @JoinColumn(name = "contract_id", nullable = false) }, inverseJoinColumns = { @JoinColumn(name = "project_id", nullable = false) })
	public Set<PoProject> getProjectSet() {
		return projectSet;
	}

	public void setProjectSet(Set<PoProject> projectSet) {
		this.projectSet = projectSet;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "contract_contact", joinColumns = { @JoinColumn(name = "contract_id", nullable = false) }, inverseJoinColumns = { @JoinColumn(name = "contact_id", nullable = false) })
	public Set<PoContact> getContactSet() {
		return contactSet;
	}

	public void setContactSet(Set<PoContact> contactSet) {
		this.contactSet = contactSet;
	}

	public Integer getSeq() {
		return seq;
	}

	public void setSeq(Integer seq) {
		this.seq = seq;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "contract")
	public Set<PoContractPhoto> getContractPhotoSet() {
		return contractPhotoSet;
	}

	public void setContractPhotoSet(Set<PoContractPhoto> contractPhotoSet) {
		this.contractPhotoSet = contractPhotoSet;
	}

	
	
	/*
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "project_contract", joinColumns = { @JoinColumn(name = "contract_id", nullable = false) }, inverseJoinColumns = { @JoinColumn(name = "project_id", nullable = false) })
	public Set<PoProject> getProjectSet() {
		return projectSet;
	}

	public void setProjectSet(Set<PoProject> projectSet) {
		this.projectSet = projectSet;
	}

	public float getAmount() {
		return amount;
	}

	public void setAmount(float amount) {
		this.amount = amount;
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}*/
	
	
	
}
